//
//  MyComplainJudgeViewController.m
//  PropertyManager
//
//  Created by TNG on 2018/8/13.
//  Copyright © 2018年 Tng. All rights reserved.
//

#import "MyComplainJudgeViewController.h"

@interface MyComplainJudgeViewController () <UITextViewDelegate>

@property (strong, nonatomic) UITextView * textView;
@property (strong, nonatomic) UILabel * numLabel;
@property (strong, nonatomic) UILabel * placeLabel;

@end

@implementation MyComplainJudgeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = SFM242;
    self.title = @"评价";
    [self.view addSubview:self.textView];
    [self.view addSubview:self.placeLabel];
    [self.view addSubview:self.numLabel];
}

-(UITextView *)textView
{
    if (_textView == nil) {
        _textView = [[UITextView alloc] initWithFrame:CGRectMake(20 , 15 + kStatusAndNavBarH, WIDTH - 40, 180)];
        _textView.font = font(16);
        _textView.delegate = self;
        _textView.textColor = SFM153;
    }
    return _textView;
}

-(UILabel *)placeLabel
{
    if (_placeLabel == nil) {
        _placeLabel =[[UILabel alloc]initWithFrame:CGRectMake(26, 19  + kStatusAndNavBarH, WIDTH - 52, 50)];
        _placeLabel.font =font(16);
        _placeLabel.textColor=SFMColor(153, 153, 153);
        _placeLabel.text = @"说说您对本次物业服务的想法，如专业水平、服务态度等是否满意。";
        _placeLabel.numberOfLines = 0;
        _placeLabel.textAlignment=NSTextAlignmentLeft;
    }
    return _placeLabel;
}

-(UILabel *)numLabel
{
    if (_numLabel == nil) {
        _numLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 195  + kStatusAndNavBarH, WIDTH - 40, 20)];
        _numLabel.font = font(16);
        _numLabel.textColor = SFM153;
        _numLabel.textAlignment = NSTextAlignmentRight;
        _numLabel.attributedText = [NSMutableAttributedString headStr:@"" AndMiddleStr:@"0" AndFootStr:@" / 200" AndFont:font(16) AndTextColor:SFMColor(246, 110, 36)];
    }
    return _numLabel;
}

-(void)textViewDidChange:(UITextView *)textView
{
    if (textView.text.length == 0) {
        self.placeLabel.hidden = NO;
    }
    else {
        self.placeLabel.hidden = YES;
    }
    NSString * text = textView.text;
    if(text.length>200)
    {
        textView.text = [text substringToIndex:200];
    }
    self.numLabel.attributedText = [NSMutableAttributedString headStr:@"" AndMiddleStr:[NSString stringWithFormat:@"%d",(int)textView.text.length] AndFootStr:@" / 200" AndFont:font(16) AndTextColor:SFMColor(246, 110, 36)];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
